import { ApiProperty } from '@nestjs/swagger'
import { IsArray, IsOptional, IsString } from 'class-validator'

import { PagerDto } from '~/common/dto/pager.dto'

export class LoginLogQueryDto extends PagerDto {
  @ApiProperty({ description: '用户名' })
  @IsString()
  @IsOptional()
  username: string

  @ApiProperty({ description: '登录IP' })
  @IsOptional()
  @IsString()
  ip?: string

  @ApiProperty({ description: '登录地点' })
  @IsOptional()
  @IsString()
  address?: string

  @ApiProperty({ description: '登录时间' })
  @IsOptional()
  @IsArray()
  time?: string[]
}

export class TaskLogQueryDto extends PagerDto {
  @ApiProperty({ description: '用户名' })
  @IsOptional()
  @IsString()
  username: string

  @ApiProperty({ description: '登录IP' })
  @IsString()
  @IsOptional()
  ip?: string

  @ApiProperty({ description: '登录时间' })
  @IsOptional()
  time?: string[]
}

export class CaptchaLogQueryDto extends PagerDto {
  @ApiProperty({ description: '用户名' })
  @IsOptional()
  @IsString()
  username: string

  @ApiProperty({ description: '验证码' })
  @IsString()
  @IsOptional()
  code?: string

  @ApiProperty({ description: '发送时间' })
  @IsOptional()
  time?: string[]
}

export class LoginLogResponseDto {
  @ApiProperty({ description: '日志ID' })
  id: number

  @ApiProperty({ description: '日志类型' })
  logType: number

  @ApiProperty({ description: '用户ID' })
  userId: number

  @ApiProperty({ description: '用户类型' })
  userType: number

  @ApiProperty({ description: '追踪ID' })
  traceId: string

  @ApiProperty({ description: '用户名' })
  username: string

  @ApiProperty({ description: '登录结果' })
  result: number

  @ApiProperty({ description: '用户IP' })
  userIp: string

  @ApiProperty({ description: '用户代理' })
  userAgent: string

  @ApiProperty({ description: '创建时间' })
  createTime: number
}
